package com.bamboohat;

/**
 * 栈内存溢出
 * VM args : -Xss128k -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails
 */
public class JavaVMStackSOF {

    private int stackLength = 1;

    public void stackLeak() {
        stackLength++;
        stackLeak();
    }

    public static void  main(String[] args) throws Throwable {
        JavaVMStackSOF oom = new JavaVMStackSOF();

        try {
            oom.stackLeak();
        } catch (Exception e) {
            System.out.println("stack length : " + oom.stackLength);
            throw e;
        }
    }
}
